package com.springcloud.test;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Desc TODO
 * ----------------
 * @CLASS_NAME: Trace1Controller
 * ----------------
 * @Author jovi
 * ----------------
 * @Date 2020-03-31 09:45
 */
@RestController
@Slf4j
public class Trace1Controller {

    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @GetMapping("/trace-1")
    public String trace() {
        log.info("======call trace-1======");
        return restTemplate().getForEntity("http://localhost:8051/trace-2", String.class).getBody();
    }
}
